/**
 *
 */
import java.util.List;
import java.util.ArrayList;
import java.util.Random;

public class CardDemo {

    //必须是static
    public static String[] SUITS = {"♠", "♥", "♣", "♦"};

    //必须是static
    public static List<Card> buydeck() {
        List<Card> deck = new ArrayList<>(52);
        for (int i = 0; i < 4; i++) {
            for (int j = 1; j <= 13; j++) {
                String suit = SUITS[i];
                int rank = j;
                Card card = new Card();
                card.rank = rank;
                card.suit = suit;
                deck.add(card);
            }
        }
        return deck;
    }

    //List 后面一定要跟尖括号
    public static void shuffle(List<Card> card){
        Random random=new Random();
        for (int i= card.size()-1;i>0;i--){
            int index=random.nextInt(i);
            Card tmp=card.get(index);
            card.set(index,card.get(i));
            card.set(i,tmp);
        }


    }


    public static void main(String[] args) {
        //打印牌
        List<Card> deck = buydeck();
        System.out.println("买牌"+deck);
       shuffle(deck);
        System.out.println("洗牌"+deck);
    }
}